#!/bin/bash

localPath="/repo/rhel7osp5/"
fileConn="/getPackage/"

## RHEL 7 OSP 5
# rhel-7-server-rpms
# rhel-7-server-rh-common-rpms
# rhel-7-server-openstack-5.0-rpms

for i in rhel-7-server-rpms rhel-7-server-rh-common-rpms rhel-7-server-openstack-5.0-rpms
do

  mkdir -p "$localPath"$i"$fileConn"
  rm -rf "$localPath"$i"$fileConn"repodata

done

  echo "sync channel $i..."
  reposync --plugins --newest-only --delete --download_path="$localPath" --repoid=rhel-7-server-rpms --repoid=rhel-7-server-rh-common-rpms --repoid=rhel-7-server-openstack-5.0-rpms

for i in rhel-7-server-rpms rhel-7-server-rh-common-rpms rhel-7-server-openstack-5.0-rpms
do

  echo "create repo $i..."
  createrepo "$localPath"$i"$fileConn"

done

exit 0

